package com.wang.study.mapper;

import com.wang.study.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from mall_admin where account=#{username}")
    User findUserByUserName(String username);
    @Select("select * from mall_admin where email=#{email}")
    User findUserByEmail(String email);
    @Insert("insert into mall_admin(account,password,email,activeCode) values(#{account},#{password},#{email},#{activeCode})")
    Integer inserUser(User user);
    @Update("update mall_admin set status=1 where activeCode=#{activeCode}")
    void updateUserStateByActiveCode(String activeCode);
    @Select("select * from mall_admin where account=#{account}")
    User selectByUser(String account);
    @Select("select * from mall_admin")
    List<User> findUserAll();
    @Delete("delete from mall_admin where id=#{id}")
    Integer delUserById(Integer id);
    @Insert("insert into mall_admin(account,password,email,status) values(#{account},#{password},#{email},#{status})")
    Integer addUser(@Param("account")String account,@Param("password")String password,@Param("email")String email,@Param("status")Integer status);
    @Update("update mall_admin set account=#{account},password=#{password},email=#{email},status=#{status} where id=#{id}")
    Integer updateUserById(@Param("account")String account,@Param("password")String password,@Param("email")String email,@Param("status")Integer status,@Param("id") Integer id);
    @Update("update mall_admin set password=#{pwd} where account=#{account}")
    Integer updatePwd(@Param("account") String username, @Param("pwd") String md5);
    @Select("select * from mall_admin where account=#{username}")
    User selectUserByUsername(String username);
}
